package com.api.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.api.dao.ApiMapper;
import com.api.entity.Api;
import com.api.service.ApiService;

@Service
public class ApiServiceImpl implements ApiService{
	
	@Autowired
	private ApiMapper apiMapper;

	@Override
	@Cacheable(value="api",key="#id")
	public Api get(String id) {
		return this.apiMapper.selectByPrimaryKey(id);
	}

	@Override
	@CachePut(value="api",key="#api.id")
	public int add(Api api) {
		api.preInsert();
		return this.apiMapper.insert(api);
	}

	@Override
	@CachePut(value="api",key="#api.id")
	public int update(Api api) {
		return this.apiMapper.update(api);
	}

	@Override
	public List<Api> getApiList(String projectId) {
		return this.apiMapper.getApiList(projectId);
	}
	

}
